package com.rowline.admin.module.study.mybatiscache;

import org.apache.ibatis.session.SqlSession;

import java.sql.SQLException;

/**
 * ClassName:MybatisCacheDemo01
 * Created by 245167
 * on 2018/4/28  28:53
 * description:
 */
public class MybatisCacheDemo01 {

    public static void main(String[] args) {
        // 使用工厂类获得SqlSession对象
        SqlSession sqlSession = MySqlSessionFactory.getSqlSession();
        // 获得InterAgencyMapper对象
        InterAgencyMapper interAgencyMapper = sqlSession.getMapper(InterAgencyMapper.class);
        Long id = 5L;
        InterAgencyInfo agencyInfo = null;

        try {
            agencyInfo = interAgencyMapper.queryAgencyInfoById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        System.out.println("1 - 查询到数据为 ：" + agencyInfo.toString());
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        try {
            agencyInfo = interAgencyMapper.queryAgencyInfoById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        System.out.println("2 - 查询到数据为 ：" + agencyInfo.toString());

        sqlSession.close();

    }

}
